*Set up
clear all
set memory 5g

set more off

*N.B.: Unweighted localization file;


*log using "\\ead02\ead_uquam\Localization\restat_results", replace 

use "\\ead02\ead_uquam\Localization\NAICS6_panel\restat_final.dta", clear

cd "\\ead02\ead_uquam\Localization\restat_results"


*TSET FUNCTION;

destring naics, replace
destring oecd80, replace

xtset naics year, delta(1)


*log using "\\ead02\ead_uquam\Localization\restat_dstats", replace

//Table 1: Summary statistics for geographic concentration  and transportation costs

xtsum  cdf10 cdf25 cdf50 cdf100 localised pi av_klems

//Table 4: Summary statistics for control variables

gen rdlshr1 = rdlshr*1000

xtsum m_asiashr m_oecdshr m_naftashr x_asiashr x_oecdshr x_naftashr av_klems l_idist_n5 l_odist_n5 distn5 nrs  peeshr empl herfent m_emp nmulti1 nfown ifqh3shr rdlshr1 ewshare port_dist  av_klemsus 

//Figure 2
mean m_naftashr m_oecdshr m_asiashr, over(year)


//Table 10

//Top 10 and Bottom 10

gen top10 = 0

replace top10 = 1 if naics == 327420 
replace top10 = 1 if naics == 327310 
replace top10 = 1 if naics == 327410 
replace top10 = 1 if naics == 327910 
replace top10 = 1 if naics == 327990 
replace top10 = 1 if naics == 321111 
replace top10 = 1 if naics == 325181 
replace top10 = 1 if naics == 321999 
replace top10 = 1 if naics == 312120
replace top10 = 1 if naics == 327320

gen bottom10 = 0

replace bottom10 = 1 if naics == 334210
replace bottom10 = 1 if naics == 334511
replace bottom10 = 1 if naics == 334220
replace bottom10 = 1 if naics == 334110
replace bottom10 = 1 if naics == 334290
replace bottom10 = 1 if naics == 336110
replace bottom10 = 1 if naics == 333291
replace bottom10 = 1 if naics == 339110
replace bottom10 = 1 if naics == 312220
replace bottom10 = 1 if naics == 337123

mean av_klems, over(top10 year)

mean av_klems, over(bottom10 year)

*Figure 7

//CDF and ad valorem trasport cost K-densities

gen av_klems_base = exp(lnav_klems)

kdensity av_klems_base
graph save kdensity_av_klems, replace

kdensity lnav_klems
graph save kdensity_lnav_klems, replace

summ lnav_klems

summ cdf50


kdensity cdf50
graph save kdensity_cdf50, replace

kdensity lncdf50
graph save kdensity_lncdf50, replace

*log close

*end

